package cn.minsh.lims.eoms.modules.app.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.minsh.lims.eoms.common.utils.PageUtils;
import cn.minsh.lims.eoms.common.utils.Query;

import cn.minsh.lims.eoms.modules.app.dao.PlanScopeDao;
import cn.minsh.lims.eoms.modules.app.entity.PlanScopeEntity;
import cn.minsh.lims.eoms.modules.app.service.PlanScopeService;


@Service("planScopeService")
public class PlanScopeServiceImpl extends ServiceImpl<PlanScopeDao, PlanScopeEntity> implements PlanScopeService {

    @Autowired
    private PlanScopeDao planScopeDao ;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<PlanScopeEntity> page = this.page(
                new Query<PlanScopeEntity>().getPage(params),
                new QueryWrapper<PlanScopeEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void deleteByPlanId(Integer type,Long planId) {
        QueryWrapper<PlanScopeEntity> queryWrapper = new QueryWrapper<>() ;
        queryWrapper.eq("type",type) ;
        queryWrapper.eq("plan_id",planId) ;
        planScopeDao.delete(queryWrapper) ;
    }

    @Override
    public List<PlanScopeEntity> listByTypeAndPlanId(Integer type, Long planId) {
        QueryWrapper<PlanScopeEntity> queryWrapper = new QueryWrapper<>() ;
        queryWrapper.eq("type",type) ;
        queryWrapper.eq("plan_id",planId) ;
        return planScopeDao.selectList(queryWrapper);
    }

}